home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 33 / Amiga Format AFCD33 (Issue 117, Dec 1998).iso / -seriously_amiga- / graphics / visualengineer / arexx / scaler.rexx < prev    next >
OS/2 REXX Batch file  |  1998-09-07  |  2KB  |  121 lines

  1. /*
  2.    Scaler v1.00
  3.  
  4.    by Marko Seppänen
  5.  
  6.    marko.seppanen@wwnet.fi
  7. */
  8.  
  9.  
  10. address IMAGEENGINEER
  11.  
  12. Options results
  13. signal on error            /* Setup a place for errors to go */
  14.  
  15. x=arg(1)
  16. text=subword(x,1,1)
  17. type=space(subword(x,2,1),0)
  18.  
  19.  
  20. 'GET_FILES "Choose some pictures..." "Ok" "gfx:Art/"'
  21. filelist=result
  22. if RC=5 then exit
  23.  
  24.  
  25.  
  26. /*  HOW MANY PHILEZ  */
  27.  
  28. files=0
  29.  
  30. filist=filelist
  31.  
  32. do while filist~=""
  33.   parse var filist pic ';' filist
  34.   files=files+1
  35. end
  36.  
  37. if files=1 then do
  38.   'REQUEST "Only one picture ??" "Sorry"'
  39.   exit
  40. end
  41.  
  42.  
  43.  
  44.  
  45. if exists("ie:prefs/scaler.cfg") == "1" then
  46.   do
  47.     call open("temp","ie:prefs/scaler.cfg","R")
  48.     values=readln("temp")
  49.     parse var values ok max min
  50.     call close("temp")
  51.   end
  52. else
  53.   do
  54.     max=100
  55.     min=70
  56.   end
  57.  
  58. 'FORM "Scaler" "Use|Cancel"',
  59. ' INTEGER,"Maximum X&Y",8,256,'max',SLIDER',
  60. ' INTEGER,"Minimum %",1,100,'min',SLIDER'
  61.  
  62. values=result
  63. parse var values ok max min
  64. if ok = 0 then exit
  65.  
  66. call open("temp","ie:prefs/scaler.cfg","W")
  67. res=writeln("temp",values)
  68. call close("temp")
  69.  
  70.  
  71.  
  72. minimum=max/100*min
  73. temp=(max-minimum)/(files-1)
  74. ListOfPics=""
  75.  
  76. do i=0 to files-1
  77.  
  78.   parse var filelist pic ';' filelist
  79.   OPEN "'"pic"'" COLOUR
  80.   pic=result
  81.   MARK pic PRIMARY
  82.  
  83.   step=temp*i
  84.   SCALE pic minimum+step minimum+step BEST
  85.   pic2=result
  86.  
  87.   ListOfPics=insert(ListOfPics,pic2)
  88.   ListOfPics=insert(ListofPics,";")
  89.  
  90.   CLOSE pic
  91.  
  92. end
  93.  
  94.  
  95. if text="GimmeSumScaledPics" then do
  96.   ListOfPics=delstr(ListOfPics,length(ListOfPics),1)
  97.   call open("tempfile","ram:List-o-Pictures.file","W")
  98.   call writeln("tempfile",ListOfPics)
  99.   call close("tempfile")
  100. end
  101.  
  102. exit
  103.  
  104. /*******************************************************************/
  105. /* This is where control goes when an error code is returned by IE */
  106. /* It puts up a message saying what happened and on which line     */
  107. /*******************************************************************/
  108. error:
  109. if RC=5 then do            /* Did the user just cancel us? */
  110.     IE_TO_FRONT
  111.     LAST_ERROR
  112.     'REQUEST "'||RESULT||'"'
  113.     exit
  114. end
  115. else do
  116.     IE_TO_FRONT
  117.     LAST_ERROR
  118.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  119.     exit
  120. end
  121.